package cn.edu.huanu.pojo;

import java.util.Objects;

/**
 * @author hb
 * @date 2025-11-14 15:47:16
 */
public class CartItem {
    //商品
    private Book product;
    //商品数量
    private double qty;

    public CartItem( ) {

    }

    public CartItem(Book book, double qty) {
        this.product = book;
        this.qty = qty;
    }

    @Override
    public boolean equals(Object o) {
        if(o==null) return false;
        if(o==this) return true;
        if(o instanceof CartItem){
            CartItem other=(CartItem)o;
            return this.product.getId().equals(other.product.getId()) ;
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(product.getId());
    }

    public Book getProduct() {
        return product;
    }

    public void setProduct(Book product) {
        this.product = product;
    }

    public double getQty() {
        return qty;
    }

    public void setQty(double qty) {
        this.qty = qty;
    }
}
